package com.abbas.smartCity.adapter;

import com.abbas.smartCity.App;
import com.bumptech.glide.Glide;
import com.youth.banner.adapter.BannerImageAdapter;
import com.youth.banner.holder.BannerImageHolder;

import java.util.List;

/**
 * 再次重写 BannerImageAdapter，无需再实现 onBindView 。拿来就用，直接new
 * @param <T> 数据类型
 */
public class BannerImageAdapter2<T> extends BannerImageAdapter<T> {

    public BannerImageAdapter2(List<T> mData) {
        super(mData);
    }

    @Override
    public void onBindView(BannerImageHolder bannerImageHolder, Object o, int i, int i1) {
        if (o instanceof Integer){
            Glide.with(bannerImageHolder.imageView)
                    .load(o)
                    .into(bannerImageHolder.imageView);
        }else if (o instanceof String){
            Glide.with(bannerImageHolder.imageView)
                    .load(App.getBaseUrl() + o)
                    .into(bannerImageHolder.imageView);
        }
    }
}
